home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 September (IDG) / Sep99.iso / Shareware World / Comms & Internet / LinkConverter 1.1.2 / Dialog Director v0.7 / Examples / Search osaxen.as < prev    next >
Encoding:
Text File  |  1998-02-01  |  2.4 KB  |  71 lines  |  [TEXT/ToyS]

  1. property inquiredTerm : ""
  2. set inquiredTerm to text returned of ¬
  3.     (display dialog "Which term do you wish to search for?" default answer inquiredTerm)
  4. if inquiredTerm is "" then return
  5.  
  6. -- get osax list
  7. try
  8.     -- error -- If this won’t compile, comment out the line below this and uncomment this line
  9.     set osaxFolder to path to scripting additions folder as string
  10. on error
  11.     set osaxFolder to (path to extensions folder as string) & "Scripting Additions:"
  12. end try
  13. tell application "Finder" to ¬
  14.     set osaxList to name of (every file whose file type is "osax") in folder osaxFolder
  15. if osaxList is {} then return
  16.  
  17. set matchedOsaxen to []
  18. repeat with o in osaxList -- get aete suites from file
  19.     set rf to null
  20.     try
  21.         set rf to res open file (osaxFolder & o) --without write permission
  22.         set aeteSuites to res get rf id 0 type "aete"
  23.         res close rf
  24.         set rf to null
  25.         
  26.         set aeteSuites to item 5 of (cast aeteSuites without label)
  27.         repeat with s in aeteSuites -- may be more than one suite
  28.             set suiteName to s's first item
  29.             -- get commands
  30.             set suiteCommands to s's item 6
  31.             repeat with c in suiteCommands
  32.                 set eventTerm to c's first item
  33.                 if eventTerm contains inquiredTerm then ¬
  34.                     set matchedOsaxen to matchedOsaxen & [{name:o as string, term:eventTerm}]
  35.             end repeat
  36.         end repeat
  37.     on error --number -192 -- aete resource not found
  38.         if rf ≠ null then res close rf
  39.     end try
  40. end repeat
  41.  
  42. -- release memory
  43. set [osaxList, aeteSuites, suiteName, suiteCommands, eventTerm] to [null, null, null, null, null]
  44.  
  45. -- report matches
  46. if matchedOsaxen is {} then
  47.     display dialog "No matches were found in the Scripting Additions folder." buttons "OK" default button 1 with icon stop
  48.     return
  49. end if
  50.  
  51. set reportName to "Matches found for ‘" & inquiredTerm & "’"
  52. set lastOsax to ""
  53. set dItems to []
  54. set y to 8
  55. repeat with o in matchedOsaxen
  56.     if o's name ≠ lastOsax then
  57.         set dItems to dItems & [{class:static text, bounds:[10, y, 150, y + 12], contents:o's name, font:2, justification:right}, ¬
  58.             {class:static text, bounds:[155, y, 335, y + 12], contents:o's term}]
  59.         set lastOsax to o's name
  60.         set y to y + 16
  61.     else
  62.         set y to y + 12
  63.         tell dItems's last item
  64.             set contents to contents & return & o's term
  65.             set bounds's item 4 to y
  66.         end tell
  67.     end if
  68. end repeat
  69. set dItems to dItems & [{class:push button, bounds:[280, 10, 330, 28], name:"OK"}]
  70.  
  71. dd auto dialog {size:[340, y + 8], contents:dItems, style:movable dialog, name:reportName} with fonts [{name:"Geneva", size:9}, {style:bold}]